/*
 * @Author: hongbin
 * @Date: 2022-09-24 12:34:23
 * @LastEditors: hongbin
 * @LastEditTime: 2022-09-24 16:19:51
 * @Description:透明模糊材质
 */

import * as THREE from "three";

const baseParams = {
    color: 0xdd3311,
    //类似透明度
    transmission: 0.9,
    opacity: 1,
    //金属度
    metalness: 0,
    //粗糙
    roughness: 1,
    //折射率
    ior: 1,
    //厚度 透过看物体的模糊程度
    thickness: 0,
    //镜面强度
    specularIntensity: 1,
    //镜面颜色
    // specularColor: new THREE.Color("#f55fff"),
};

export const vagueMaterial = (params?: Partial<typeof baseParams>) => {
    const material = new THREE.MeshPhysicalMaterial({
        side: THREE.DoubleSide,
        flatShading: true,
        ...baseParams,
        ...params,
    });

    // for (const key of Object.keys(baseParams)) {
    //     //@ts-ignore
    //     isNaN(baseParams[key]) &&
    //         window.gui.add(baseParams, key, 0, 2).onChange((v) => {
    //             //@ts-ignore
    //             material[key] = v;
    //             window.render();
    //         });
    // }

    return material;
};
